import os
from openai import OpenAI

api_key=os.getenv("DASHSCOPE_API_KEY")
client = OpenAI(api_key="XXXX", base_url="https://api.deepseek.com")

# Round 1
messages = [{"role": "user", "content": "9.11和9.8哪个大?"}]
response = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=messages,
    stream=True
)

reasoning_content = ""
content = ""

for chunk in response:
    if chunk.choices[0].delta.reasoning_content:
        print(chunk.choices[0].delta.reasoning_content, end='')
        reasoning_content += chunk.choices[0].delta.reasoning_content
    else:
        print(chunk.choices[0].delta.content, end='')

